#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;

namespace Utility.Attributes {

    [CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
    public class ReadOnlyDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            bool wasEnabled = GUI.enabled;
            GUI.enabled = false; // 禁用 GUI（变灰并不可编辑）

            EditorGUI.PropertyField(position, property, label, true);

            GUI.enabled = wasEnabled; // 恢复 GUI 状态
        }

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            return EditorGUI.GetPropertyHeight(property, label, true);
        }
    }
}
#endif